package com.guoyh.baseutils.ext

import android.graphics.Color
import androidx.annotation.ColorRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.guoyh.baseutils.appContext
import com.xuexiang.xui.utils.ResUtils

/**
 * @CreateDate: 7/14/21 1:46 PM
 * @Author: guoyh
 * @Description: 资源文件相关的Ext
 */
fun getColorm(@ColorRes color: Int) = ResUtils.getColor(color)

fun getColorm(color: String, alpha: String = "FF"): Int {
    if (alpha == "FF") {
        return Color.parseColor(color)
    } else {
        return Color.parseColor(
            color.replace(
                "#",
                "#${alpha}"
            )
        )

    }
}


fun getDrawablem(@DrawableRes drawableId: Int) = ResUtils.getDrawable(appContext,drawableId)

fun getStringm(@StringRes id: Int) = appContext.resources.getString(id)

fun getStringArraym(id: Int): Array<String> = appContext.resources.getStringArray(id)

fun getIntArraym(id: Int) = appContext.resources.getIntArray(id)

fun getDimensionm(id: Int) = appContext.resources.getDimension(id)
